package com.xingyun.di.module;

import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;

import com.jess.arms.di.scope.ActivityScope;
import com.xingyun.mvp.contract.VideoContract;
import com.xingyun.mvp.model.VideoModel;
import com.xingyun.mvp.ui.home.adapter.VideoAdapter;
import com.xingyun.mvp.ui.home.adapter.bean.VideoCover;

import java.util.ArrayList;
import java.util.List;

import dagger.Module;
import dagger.Provides;


@Module
public class VideoModule {
    private VideoContract.View view;

    /**
     * 构建VideoModule时,将View的实现类传进来,这样就可以提供View的实现类给presenter
     *
     * @param view
     */
    public VideoModule(VideoContract.View view) {
        this.view = view;
    }

    @ActivityScope
    @Provides
    VideoContract.View provideVideoView() {
        return this.view;
    }

    @ActivityScope
    @Provides
    VideoContract.Model provideVideoModel(VideoModel model) {
        return model;
    }

    @ActivityScope
    @Provides
    RecyclerView.LayoutManager provideLayoutManager() {
        return new GridLayoutManager(view.getActivity(), 2);
    }

    @ActivityScope
    @Provides
    List<VideoCover> provideVideoList() {
        return new ArrayList<>();
    }

    @ActivityScope
    @Provides
    RecyclerView.Adapter provideUserAdapter(List<VideoCover> list){
        return new VideoAdapter(list);
    }

}